package com.chapter10;

import java.util.Objects;

/**
 * 对称性
 */
public final class caseEqualse {

    private final String s;

    public caseEqualse(String s){
        this.s= Objects.requireNonNull(s);
    }


    @Override
    public boolean equals(Object o) {
        if (o instanceof caseEqualse)
            return s.equalsIgnoreCase(((caseEqualse)o).s);
        if (o instanceof String)
            return s.equalsIgnoreCase((String)o);
        return false;
    }

    public static void main(String[] args) {
        caseEqualse c=new caseEqualse("abC");
        String s="abc";
        System.out.println(c.equals(s));
        System.out.println(s.equals(c));
    }


}
